home *** CD-ROM | disk | FTP | other *** search
- /*
- | Utility name: SetInputFlag.c
- |
- | USAGE:
- |
- | SetInputFlag.x <viewfile> <viewfile> ... <viewfile>
- |
- | DESCRIPTION:
- |
- | Set the new flag REDRAW_ON_UPDATE (flag added at release 9.1) for
- | all input objects found in the specified view(s). The flag
- | is set using the DV-Tools routine VOinPutFlag. This flag
- | allows the redrawing of obscuring objects that have been
- | damaged by input object updates.
- */
-
- /*
- * DV-Tools header files
- */
- #include "std.h" /* <stdio.h> etc., scalar & macro definitions */
- #include "dvstd.h" /* public types & constants */
- #include "dvtools.h" /* constants used by T routines */
- #include "dvinteract.h" /* needed for input objects & event handler */
- #include "dvGR.h" /* constants used by window mgt & GR routines */
- #include "VOstd.h" /* constants used by VO & VOob routines */
- #include "Tfundecl.h" /* T routines (screens, drawports & views) */
- #include "VOfundecl.h" /* VO routines (objects) */
- #include "VNsetup.h" /* info for interaction handlers */
-
- /* Constants */
- #define DVPATH (CHAR *)NULL
- #define DVCOLORTABLE (CHAR *)NULL
-
- /* Functions defined in SetInputFlag.c */
- int main V_P_((int argc, char *argv[]));
- LOCAL ADDRESS SetInputFlag V_P_((OBJECT object, ADDRESS args));
- LOCAL BOOLPARAM IsWidget V_P_((OBJECT input_tech));
- /***************** End Function Declarations *************/
-
- /*
- * MAIN PROGRAM
- */
- int
- main (argc, argv)
- int argc;
- char *argv[];
- {
- CHAR *view_name = NULL;
- VIEW view;
- INT i;
-
- (VOID) TInit (DVPATH, DVCOLORTABLE);
- if (argc <= 1)
- {
- (VOID) S_PRINTF ("Name of view file to convert must be specified.\n");
- S_EXIT (EXIT_ERR);
- }
-
- for (i = 1; i < argc; ++i)
- {
- view_name = argv[i];
- view = TviLoad (view_name);
- if (!view)
- {
- (VOID) S_PRINTF ("Could not load view from file ");
- (VOID) S_PRINTF ("%s.\n", view_name);
- S_EXIT (EXIT_ERR);
- }
-
- /*
- * For each object in the drawing of the specified view call
- * the function SetInputFlag. This function will set the
- * flag for all input objects.
- */
- (VOID) TobForEachSubobject (TviGetDrawing (view), SetInputFlag,
- (ADDRESS) NULL);
- /*
- * Save changes made to objects in view and destroy
- * the current view freeing the allocated memory.
- */
- (VOID) S_PRINTF (
- "REDRAW_ON_UPDATE flag set for input objects in view, %s.\n",
- view_name);
- (VOID) TviSave (view, view_name);
- (VOID) TviDestroy (view);
- }
-
- /* Perform the clean-up for DV-Tools */
- (VOID) TTerminate ();
- return (EXIT_OK);
- }
-
- /*--------------
- * SetInputFlag -- set the flag, REDRAW_ON_UPDATE, to yes
- * for all input objects except those which
- * which are widget-based.
- */
- LOCAL ADDRESS
- SetInputFlag (object, args)
- OBJECT object;
- ADDRESS args;
- {
- OBJECT input_tech, template = (OBJECT) NULL;
-
- /*
- * If the object is an input object then get the interaction
- * handler. Then set the REDRAW_ON_UPDATE flag to yes if
- * the interaction handler represents a non-widget-based
- * interaction handler. Then obtain the template for the
- * interaction handler and traverse all the objects in the
- * template searching for embedded input objects.
- */
- if (VOobType (object) == OT_INPUT)
- {
- input_tech = VOinTechnique (object, (OBJECT) DONT_SET_THE_VALUE);
-
- /* Set the flag */
- if (!IsWidget (input_tech))
- (VOID) VOinPutFlag (object, (INT) REDRAW_ON_UPDATE, (INT) YES);
-
- /* Traverse the template for the embedded inputs */
- template = VOitGetTemplate (input_tech);
- if (template)
- (VOID) VOdrTraverse (template, (VOOBTRAVERSEFUN)SetInputFlag, (ADDRESS) NULL);
- }
- else if (VOobType (object) == OT_SUBDRAWING)
- (VOID) VOdrTraverse (VOsdDrGet (object), (VOOBTRAVERSEFUN)SetInputFlag, (ADDRESS) NULL);
-
- return (ADDRESS) V_CONTINUE_TRAVERSAL;
- }
-
- /*----------
- * IsWidget -- Check to see if the passed input object
- * a DataViews widget-based input object.
- * The DataViews widget-based input objects
- * do not have a TakeInput state.
- */
- LOCAL BOOLPARAM
- IsWidget (input_tech)
- OBJECT input_tech;
- {
- ADDRESS (*GetDispatchTable) ()= NULL;
- INT (**dispatch) ();
-
- GetDispatchTable = (ADDRESS (*)())VOitGetInteraction (input_tech);
- if (GetDispatchTable)
- dispatch = (INT (**)())(*GetDispatchTable) ((ADDRESS) 0);
- if (!dispatch[IH_TAKE_INPUT])
- return YES;
- return NO;
- }
-